home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
jcool01.zip
/
EX4_9.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-24
|
1KB
|
29 lines
//
// Copyright (C) 1991 Texas Instruments Incorporated.
//
// Permission is granted to any individual or institution to use, copy, modify,
// and distribute this software, provided that this complete copyright and
// permission notice is maintained, intact, in all copies and supporting
// documentation.
//
// Texas Instruments Incorporated provides this software "as is" without
// express or implied warranty.
//
// Updated: JAM 08/21/92 -- made j long and output it (so loop not optimized)
#include <iostream.h>
#include <cool/Timer.h> // Includer COOL timer class
int main (void) {
CoolTimer t1; // Create a CoolTimer object
volatile long sum = 0; // use in loop to discourage optimizations
t1.mark (); // Set start reference point
for (long i = 0; i < 1000000L; i++) // Loop for 1000000 times and
sum = sum + i; // Sum up numbers
long elapsed = t1.real();
cout << "Summation of integers from 0 through 1000000 (" << sum << ") took ";
cout << elapsed << " milliseconds\n"; // Output time since mark
return 0; // Return valid competion code
}